package com.offcn.util;

import java.util.List;

public class PageUtils<T> {

//    1.当前页码   			   由使用者决定
//    2.每页显示多少条数据 （页量） 由程序员决定
//    3.一共有几页               总页数  =  总记录 / 每页显示条数       10   3
//    4.一共有几条数据            总记录数  查询数据得知
//    5.当前页码的数据             查询数据库得知
    private int currentPage;
    private int pageSize;
    private int maxPage;
    private int total;
    private List<T> list;

    public PageUtils(int currentPage, int pageSize, int total, List<T> list) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.total = total;
        this.list = list;
        this.maxPage = this.total % this.pageSize == 0?this.total/this.pageSize:this.total/this.pageSize+1;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getMaxPage() {
        return maxPage;
    }

    public void setMaxPage(int maxPage) {
        this.maxPage = maxPage;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
